﻿using FluentDBC.Testing.Stubs;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace FluentDBC.Testing
{
    [TestClass]
    public class FluentDBCTesting
    {
        [TestInitialize]
        public void InitTestCase()
        {
            Container.RegisterInstance(typeof(ICustomerRepository), typeof(StubCustomerRepository));
            Container.RegisterInstance(typeof(ICustomerService), typeof(CustomerService));
            Container.RegisterInstance(typeof(ITaxStrategy), typeof(DefaultTaxStrategy));

            var obj = FluentDBCConfiguration.GetInstance()
                        .WithClass<ShoppingApplication>()
                            .Field(x => x.CustomerRepository)
                                .PreCondition()
                                .IsNotNull("CustomerRepository is null!")
                            .Field(x => x.CustomerService)
                                .PreCondition()
                                .IsNotNull("CustomerService is null!")
                            .Field(x => x.TaxStrategy)
                                .PreCondition()
                                .IsNotNull("TaxStrategy is null!")
                            .Completed();

            Container.RegisterInstance(typeof(IFluentDBCConfiguration), obj);
        }

        [TestMethod]
        public void CanCheckNotNullThatNotGetException()
        {
            var app = new ShoppingApplication();
            var report = app.ProcessingInvoiceForAllCustomers();
            Assert.IsTrue(!string.IsNullOrEmpty(report));
        }

        [TestMethod]
        public void CanCallValidationFromOutSideObject()
        {
        }

        [TestCleanup]
        public void EndTestCase()
        {
        }
    }
}